package com.se.domain.dto;

import com.se.domain.mysql.ImgDO;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;

@Data
public class ImageFileDTO {
	private String path;
	private String src;
	private MultipartFile file;
	private byte type;
	private boolean saved = false;
	
	private ImageFileDTO(String path, byte type){
		this.path = path;
		this.type = type;
	}
	
	public static ImageFileDTO buildFromFile(String path, MultipartFile file){
		ImageFileDTO dto = new ImageFileDTO(path, ImgDO.Type.LOCAL);
		dto.file = file;
		return dto;
	}
	
	public static ImageFileDTO buildFromUrl(String path, String src){
		ImageFileDTO dto = new ImageFileDTO(path, ImgDO.Type.OUTER);
		dto.src = src;
		return dto;
	}
}
